﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TryItPages
{
    public partial class WsOperations : System.Web.UI.Page
    {
        private WsOperationsService.WsOperationsServiceClient client = new WsOperationsService.WsOperationsServiceClient();

        protected void Page_Load(object sender, EventArgs e)
        {
            String requestMethod = Request.QueryString["serviceMethod"];
            String url = Request.QueryString["url"];
            if ("getWsOperations".Equals(requestMethod))
            {
                bool isError = false;
                string[] result = null;
                try
                {
                    result = this.client.getWsOperations(url);
                }
                catch (Exception ex)
                {
                    result = new string[] { ex.Message };
                    isError = true;
                }

                StringBuilder builder = new StringBuilder();
                if (isError)
                {
                    builder.Append("<div class=\"alert alert-error\">");
                    builder.Append("<button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>");
                    builder.Append("<strong>Error:</strong> Error occurred invoking the service.");
                    builder.Append("</div>");
                }

                builder.Append("<table class=\"table\">");
                builder.Append("<tr><th>Input</th><th>getWsOperations(Input)</th></tr>");
                foreach (String operation in result)
                {
                    builder.Append("<tr><td>" + url + "</td><td>" + operation + "</td></tr>");
                }
                builder.Append("</table>");
                ResultContent.Text = builder.ToString();
            }
        }
    }
}